<?php

// Create page object
$item_grid = new citem_grid();
$MasterPage =& $Page;
$Page =& $item_grid;

// Page init
$item_grid->Page_Init();

// Page main
$item_grid->Page_Main();
?>
<?php if ($item->Export == "") { ?>
<script type="text/javascript">
<!--

// Create page object
var item_grid = new ew_Page("item_grid");

// page properties
item_grid.PageID = "grid"; // page ID
item_grid.FormID = "fitemgrid"; // form ID
var EW_PAGE_ID = item_grid.PageID; // for backward compatibility

// extend page with ValidateForm function
item_grid.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	var addcnt = 0;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		var chkthisrow = true;
		if (fobj.a_list && fobj.a_list.value == "gridinsert")
			chkthisrow = !(this.EmptyRow(fobj, infix));
		else
			chkthisrow = true;
		if (chkthisrow) {
			addcnt += 1;
		elm = fobj.elements["x" + infix + "_category_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->category_id->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_name"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->name->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_price_wm"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->price_wm->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_price_wm"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($item->price_wm->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_price_em"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->price_em->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_price_em"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($item->price_em->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_price_wm_ahli"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->price_wm_ahli->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_price_wm_ahli"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($item->price_wm_ahli->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_price_em_ahli"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->price_em_ahli->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_price_em_ahli"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($item->price_em_ahli->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_weight"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->weight->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_weight"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($item->weight->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_kod"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->kod->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_rate"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->rate->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_image"];
		aelm = fobj.elements["a" + infix + "_image"];
		var chk_image = (aelm && aelm[0])?(aelm[2].checked):true;
		if (elm && chk_image && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($item->image->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_image"];
		if (elm && !ew_CheckFileType(elm.value))
			return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));

		// Set up row object
		var row = {};
		row["index"] = infix;
		for (var j = 0; j < fobj.elements.length; j++) {
			var el = fobj.elements[j];
			var len = infix.length + 2;
			if (el.name.substr(0, len) == "x" + infix + "_") {
				var elname = "x_" + el.name.substr(len);
				if (ewLang.isObject(row[elname])) { // already exists
					if (ewLang.isArray(row[elname])) {
						row[elname][row[elname].length] = el; // add to array
					} else {
						row[elname] = [row[elname], el]; // convert to array
					}
				} else {
					row[elname] = el;
				}
			}
		}
		fobj.row = row;

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
		} // End Grid Add checking
	}
	return true;
}

// Extend page with empty row check
item_grid.EmptyRow = function(fobj, infix) {
	if (ew_ValueChanged(fobj, infix, "category_id", false)) return false;
	if (ew_ValueChanged(fobj, infix, "name", false)) return false;
	if (ew_ValueChanged(fobj, infix, "price_wm", false)) return false;
	if (ew_ValueChanged(fobj, infix, "price_em", false)) return false;
	if (ew_ValueChanged(fobj, infix, "price_wm_ahli", false)) return false;
	if (ew_ValueChanged(fobj, infix, "price_em_ahli", false)) return false;
	if (ew_ValueChanged(fobj, infix, "weight", false)) return false;
	if (ew_ValueChanged(fobj, infix, "kod", false)) return false;
	if (ew_ValueChanged(fobj, infix, "rate", false)) return false;
	if (ew_ValueChanged(fobj, infix, "image", false)) return false;
	return true;
}

// extend page with Form_CustomValidate function
item_grid.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
item_grid.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
item_grid.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<?php } ?>
<?php
if ($item->CurrentAction == "gridadd") {
	if ($item->CurrentMode == "copy") {
		$bSelectLimit = EW_SELECT_LIMIT;
		if ($bSelectLimit) {
			$item_grid->TotalRecs = $item->SelectRecordCount();
			$item_grid->Recordset = $item_grid->LoadRecordset($item_grid->StartRec-1, $item_grid->DisplayRecs);
		} else {
			if ($item_grid->Recordset = $item_grid->LoadRecordset())
				$item_grid->TotalRecs = $item_grid->Recordset->RecordCount();
		}
		$item_grid->StartRec = 1;
		$item_grid->DisplayRecs = $item_grid->TotalRecs;
	} else {
		$item->CurrentFilter = "0=1";
		$item_grid->StartRec = 1;
		$item_grid->DisplayRecs = $item->GridAddRowCount;
	}
	$item_grid->TotalRecs = $item_grid->DisplayRecs;
	$item_grid->StopRec = $item_grid->DisplayRecs;
} else {
	$bSelectLimit = EW_SELECT_LIMIT;
	if ($bSelectLimit) {
		$item_grid->TotalRecs = $item->SelectRecordCount();
	} else {
		if ($item_grid->Recordset = $item_grid->LoadRecordset())
			$item_grid->TotalRecs = $item_grid->Recordset->RecordCount();
	}
	$item_grid->StartRec = 1;
	$item_grid->DisplayRecs = $item_grid->TotalRecs; // Display all records
	if ($bSelectLimit)
		$item_grid->Recordset = $item_grid->LoadRecordset($item_grid->StartRec-1, $item_grid->DisplayRecs);
}
?>
<p class="phpmaker ewTitle" style="white-space: nowrap;"><?php if ($item->CurrentMode == "add" || $item->CurrentMode == "copy") { ?><?php echo $Language->Phrase("Add") ?><?php } elseif ($item->CurrentMode == "edit") { ?><?php echo $Language->Phrase("Edit") ?><?php } ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $item->TableCaption() ?></p>
</p>
<?php $item_grid->ShowPageHeader(); ?>
<?php
$item_grid->ShowMessage();
?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div id="gmp_item" class="ewGridMiddlePanel">
<table cellspacing="0" data-rowhighlightclass="ewTableHighlightRow" data-rowselectclass="ewTableSelectRow" data-roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php echo $item->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php

// Render list options
$item_grid->RenderListOptions();

// Render list options (header, left)
$item_grid->ListOptions->Render("header", "left");
?>
<?php if ($item->category_id->Visible) { // category_id ?>
	<?php if ($item->SortUrl($item->category_id) == "") { ?>
		<td style="white-space: nowrap;"><?php echo $item->category_id->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn" style="white-space: nowrap;"><thead><tr><td><?php echo $item->category_id->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->category_id->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->category_id->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->name->Visible) { // name ?>
	<?php if ($item->SortUrl($item->name) == "") { ?>
		<td style="white-space: nowrap;"><?php echo $item->name->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn" style="white-space: nowrap;"><thead><tr><td><?php echo $item->name->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->name->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->name->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->price_wm->Visible) { // price_wm ?>
	<?php if ($item->SortUrl($item->price_wm) == "") { ?>
		<td><?php echo $item->price_wm->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->price_wm->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->price_wm->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->price_wm->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->price_em->Visible) { // price_em ?>
	<?php if ($item->SortUrl($item->price_em) == "") { ?>
		<td><?php echo $item->price_em->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->price_em->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->price_em->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->price_em->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->price_wm_ahli->Visible) { // price_wm_ahli ?>
	<?php if ($item->SortUrl($item->price_wm_ahli) == "") { ?>
		<td><?php echo $item->price_wm_ahli->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->price_wm_ahli->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->price_wm_ahli->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->price_wm_ahli->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->price_em_ahli->Visible) { // price_em_ahli ?>
	<?php if ($item->SortUrl($item->price_em_ahli) == "") { ?>
		<td><?php echo $item->price_em_ahli->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->price_em_ahli->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->price_em_ahli->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->price_em_ahli->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->weight->Visible) { // weight ?>
	<?php if ($item->SortUrl($item->weight) == "") { ?>
		<td><?php echo $item->weight->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->weight->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->weight->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->weight->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->kod->Visible) { // kod ?>
	<?php if ($item->SortUrl($item->kod) == "") { ?>
		<td><?php echo $item->kod->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->kod->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->kod->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->kod->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->rate->Visible) { // rate ?>
	<?php if ($item->SortUrl($item->rate) == "") { ?>
		<td><?php echo $item->rate->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->rate->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->rate->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->rate->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php if ($item->image->Visible) { // image ?>
	<?php if ($item->SortUrl($item->image) == "") { ?>
		<td><?php echo $item->image->FldCaption() ?></td>
	<?php } else { ?>
		<td><div>
			<table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $item->image->FldCaption() ?></td><td style="width: 10px;"><?php if ($item->image->getSort() == "ASC") { ?><img src="phpimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($item->image->getSort() == "DESC") { ?><img src="phpimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
		</div></td>		
	<?php } ?>
<?php } ?>		
<?php

// Render list options (header, right)
$item_grid->ListOptions->Render("header", "right");
?>
	</tr>
</thead>
<?php
$item_grid->StartRec = 1;
$item_grid->StopRec = $item_grid->TotalRecs; // Show all records

// Restore number of post back records
if ($objForm) {
	$objForm->Index = 0;
	if ($objForm->HasValue("key_count") && ($item->CurrentAction == "gridadd" || $item->CurrentAction == "gridedit" || $item->CurrentAction == "F")) {
		$item_grid->KeyCount = $objForm->GetValue("key_count");
		$item_grid->StopRec = $item_grid->KeyCount;
	}
}
$item_grid->RecCnt = $item_grid->StartRec - 1;
if ($item_grid->Recordset && !$item_grid->Recordset->EOF) {
	$item_grid->Recordset->MoveFirst();
	if (!$bSelectLimit && $item_grid->StartRec > 1)
		$item_grid->Recordset->Move($item_grid->StartRec - 1);
} elseif (!$item->AllowAddDeleteRow && $item_grid->StopRec == 0) {
	$item_grid->StopRec = $item->GridAddRowCount;
}

// Initialize aggregate
$item->RowType = EW_ROWTYPE_AGGREGATEINIT;
$item->ResetAttrs();
$item_grid->RenderRow();
$item_grid->RowCnt = 0;
if ($item->CurrentAction == "gridadd")
	$item_grid->RowIndex = 0;
if ($item->CurrentAction == "gridedit")
	$item_grid->RowIndex = 0;
while ($item_grid->RecCnt < $item_grid->StopRec) {
	$item_grid->RecCnt++;
	if (intval($item_grid->RecCnt) >= intval($item_grid->StartRec)) {
		$item_grid->RowCnt++;
		if ($item->CurrentAction == "gridadd" || $item->CurrentAction == "gridedit" || $item->CurrentAction == "F")
			$item_grid->RowIndex++;

		// Set up key count
		$item_grid->KeyCount = $item_grid->RowIndex;

		// Init row class and style
		$item->ResetAttrs();
		$item->CssClass = "";
		if ($item->CurrentAction == "gridadd") {
			if ($item->CurrentMode == "copy") {
				$item_grid->LoadRowValues($item_grid->Recordset); // Load row values
				$item_grid->SetRecordKey($item_grid->RowOldKey, $item_grid->Recordset); // Set old record key
			} else {
				$item_grid->LoadDefaultValues(); // Load default values
				$item_grid->RowOldKey = ""; // Clear old key value
			}
		} elseif ($item->CurrentAction == "gridedit") {
			$item_grid->LoadRowValues($item_grid->Recordset); // Load row values
		}
		$item->RowType = EW_ROWTYPE_VIEW; // Render view
		if ($item->CurrentAction == "gridadd") // Grid add
			$item->RowType = EW_ROWTYPE_ADD; // Render add
		if ($item->CurrentAction == "gridadd" && $item->EventCancelled) // Insert failed
			$item_grid->RestoreCurrentRowFormValues($item_grid->RowIndex); // Restore form values
		if ($item->CurrentAction == "gridedit") { // Grid edit
			if ($item->EventCancelled) {
				$item_grid->RestoreCurrentRowFormValues($item_grid->RowIndex); // Restore form values
			}
			if ($item_grid->RowAction == "insert")
				$item->RowType = EW_ROWTYPE_ADD; // Render add
			else
				$item->RowType = EW_ROWTYPE_EDIT; // Render edit
		}
		if ($item->CurrentAction == "gridedit" && ($item->RowType == EW_ROWTYPE_EDIT || $item->RowType == EW_ROWTYPE_ADD) && $item->EventCancelled) // Update failed
			$item_grid->RestoreCurrentRowFormValues($item_grid->RowIndex); // Restore form values
		if ($item->RowType == EW_ROWTYPE_EDIT) // Edit row
			$item_grid->EditRowCnt++;
		if ($item->CurrentAction == "F") // Confirm row
			$item_grid->RestoreCurrentRowFormValues($item_grid->RowIndex); // Restore form values
		if ($item->RowType == EW_ROWTYPE_ADD || $item->RowType == EW_ROWTYPE_EDIT) { // Add / Edit row
			if ($item->CurrentAction == "edit") {
				$item->RowAttrs = array();
				$item->CssClass = "ewTableEditRow";
			} else {
				$item->RowAttrs = array();
			}
			if (!empty($item_grid->RowIndex))
				$item->RowAttrs = array_merge($item->RowAttrs, array('data-rowindex'=>$item_grid->RowIndex, 'id'=>'r' . $item_grid->RowIndex . '_item'));
		} else {
			$item->RowAttrs = array();
		}

		// Render row
		$item_grid->RenderRow();

		// Render list options
		$item_grid->RenderListOptions();

		// Skip delete row / empty row for confirm page
		if ($item_grid->RowAction <> "delete" && $item_grid->RowAction <> "insertdelete" && !($item_grid->RowAction == "insert" && $item->CurrentAction == "F" && $item_grid->EmptyRow())) {
?>
	<tr<?php echo $item->RowAttributes() ?>>
<?php

// Render list options (body, left)
$item_grid->ListOptions->Render("body", "left");
?>
	<?php if ($item->category_id->Visible) { // category_id ?>
		<td<?php echo $item->category_id->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<?php if ($item->category_id->getSessionValue() <> "") { ?>
<div<?php echo $item->category_id->ViewAttributes() ?>><?php echo $item->category_id->ListViewValue() ?></div>
<input type="hidden" id="x<?php echo $item_grid->RowIndex ?>_category_id" name="x<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->CurrentValue) ?>">
<?php } else { ?>
<select id="x<?php echo $item_grid->RowIndex ?>_category_id" name="x<?php echo $item_grid->RowIndex ?>_category_id"<?php echo $item->category_id->EditAttributes() ?>>
<?php
if (is_array($item->category_id->EditValue)) {
	$arwrk = $item->category_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($item->category_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
if (@$emptywrk) $item->category_id->OldValue = "";
?>
</select>
<?php } ?>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_category_id" id="o<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<?php if ($item->category_id->getSessionValue() <> "") { ?>
<div<?php echo $item->category_id->ViewAttributes() ?>><?php echo $item->category_id->ListViewValue() ?></div>
<input type="hidden" id="x<?php echo $item_grid->RowIndex ?>_category_id" name="x<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->CurrentValue) ?>">
<?php } else { ?>
<select id="x<?php echo $item_grid->RowIndex ?>_category_id" name="x<?php echo $item_grid->RowIndex ?>_category_id"<?php echo $item->category_id->EditAttributes() ?>>
<?php
if (is_array($item->category_id->EditValue)) {
	$arwrk = $item->category_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($item->category_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
if (@$emptywrk) $item->category_id->OldValue = "";
?>
</select>
<?php } ?>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->category_id->ViewAttributes() ?>><?php echo $item->category_id->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_category_id" id="x<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_category_id" id="o<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->OldValue) ?>">
<?php } ?>
<a name="<?php echo $item_grid->PageObjName . "_row_" . $item_grid->RowCnt ?>" id="<?php echo $item_grid->PageObjName . "_row_" . $item_grid->RowCnt ?>"></a>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_id" id="o<?php echo $item_grid->RowIndex ?>_id" value="<?php echo ew_HtmlEncode($item->id->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { ?>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_id" id="x<?php echo $item_grid->RowIndex ?>_id" value="<?php echo ew_HtmlEncode($item->id->CurrentValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->name->Visible) { // name ?>
		<td<?php echo $item->name->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_name" id="x<?php echo $item_grid->RowIndex ?>_name" size="70" maxlength="255" value="<?php echo $item->name->EditValue ?>"<?php echo $item->name->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_name" id="o<?php echo $item_grid->RowIndex ?>_name" value="<?php echo ew_HtmlEncode($item->name->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_name" id="x<?php echo $item_grid->RowIndex ?>_name" size="70" maxlength="255" value="<?php echo $item->name->EditValue ?>"<?php echo $item->name->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->name->ViewAttributes() ?>><?php echo $item->name->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_name" id="x<?php echo $item_grid->RowIndex ?>_name" value="<?php echo ew_HtmlEncode($item->name->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_name" id="o<?php echo $item_grid->RowIndex ?>_name" value="<?php echo ew_HtmlEncode($item->name->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_wm->Visible) { // price_wm ?>
		<td<?php echo $item->price_wm->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_wm" id="x<?php echo $item_grid->RowIndex ?>_price_wm" size="70" maxlength="10" value="<?php echo $item->price_wm->EditValue ?>"<?php echo $item->price_wm->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_wm" id="o<?php echo $item_grid->RowIndex ?>_price_wm" value="<?php echo ew_HtmlEncode($item->price_wm->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_wm" id="x<?php echo $item_grid->RowIndex ?>_price_wm" size="70" maxlength="10" value="<?php echo $item->price_wm->EditValue ?>"<?php echo $item->price_wm->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->price_wm->ViewAttributes() ?>><?php echo $item->price_wm->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_wm" id="x<?php echo $item_grid->RowIndex ?>_price_wm" value="<?php echo ew_HtmlEncode($item->price_wm->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_wm" id="o<?php echo $item_grid->RowIndex ?>_price_wm" value="<?php echo ew_HtmlEncode($item->price_wm->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_em->Visible) { // price_em ?>
		<td<?php echo $item->price_em->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_em" id="x<?php echo $item_grid->RowIndex ?>_price_em" size="70" maxlength="10" value="<?php echo $item->price_em->EditValue ?>"<?php echo $item->price_em->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_em" id="o<?php echo $item_grid->RowIndex ?>_price_em" value="<?php echo ew_HtmlEncode($item->price_em->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_em" id="x<?php echo $item_grid->RowIndex ?>_price_em" size="70" maxlength="10" value="<?php echo $item->price_em->EditValue ?>"<?php echo $item->price_em->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->price_em->ViewAttributes() ?>><?php echo $item->price_em->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_em" id="x<?php echo $item_grid->RowIndex ?>_price_em" value="<?php echo ew_HtmlEncode($item->price_em->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_em" id="o<?php echo $item_grid->RowIndex ?>_price_em" value="<?php echo ew_HtmlEncode($item->price_em->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_wm_ahli->Visible) { // price_wm_ahli ?>
		<td<?php echo $item->price_wm_ahli->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" size="70" value="<?php echo $item->price_wm_ahli->EditValue ?>"<?php echo $item->price_wm_ahli->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="o<?php echo $item_grid->RowIndex ?>_price_wm_ahli" value="<?php echo ew_HtmlEncode($item->price_wm_ahli->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" size="70" value="<?php echo $item->price_wm_ahli->EditValue ?>"<?php echo $item->price_wm_ahli->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->price_wm_ahli->ViewAttributes() ?>><?php echo $item->price_wm_ahli->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" value="<?php echo ew_HtmlEncode($item->price_wm_ahli->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="o<?php echo $item_grid->RowIndex ?>_price_wm_ahli" value="<?php echo ew_HtmlEncode($item->price_wm_ahli->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_em_ahli->Visible) { // price_em_ahli ?>
		<td<?php echo $item->price_em_ahli->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" size="70" value="<?php echo $item->price_em_ahli->EditValue ?>"<?php echo $item->price_em_ahli->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="o<?php echo $item_grid->RowIndex ?>_price_em_ahli" value="<?php echo ew_HtmlEncode($item->price_em_ahli->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" size="70" value="<?php echo $item->price_em_ahli->EditValue ?>"<?php echo $item->price_em_ahli->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->price_em_ahli->ViewAttributes() ?>><?php echo $item->price_em_ahli->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" value="<?php echo ew_HtmlEncode($item->price_em_ahli->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="o<?php echo $item_grid->RowIndex ?>_price_em_ahli" value="<?php echo ew_HtmlEncode($item->price_em_ahli->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->weight->Visible) { // weight ?>
		<td<?php echo $item->weight->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_weight" id="x<?php echo $item_grid->RowIndex ?>_weight" size="70" value="<?php echo $item->weight->EditValue ?>"<?php echo $item->weight->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_weight" id="o<?php echo $item_grid->RowIndex ?>_weight" value="<?php echo ew_HtmlEncode($item->weight->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_weight" id="x<?php echo $item_grid->RowIndex ?>_weight" size="70" value="<?php echo $item->weight->EditValue ?>"<?php echo $item->weight->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->weight->ViewAttributes() ?>><?php echo $item->weight->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_weight" id="x<?php echo $item_grid->RowIndex ?>_weight" value="<?php echo ew_HtmlEncode($item->weight->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_weight" id="o<?php echo $item_grid->RowIndex ?>_weight" value="<?php echo ew_HtmlEncode($item->weight->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->kod->Visible) { // kod ?>
		<td<?php echo $item->kod->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_kod" id="x<?php echo $item_grid->RowIndex ?>_kod" size="70" maxlength="255" value="<?php echo $item->kod->EditValue ?>"<?php echo $item->kod->EditAttributes() ?>>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_kod" id="o<?php echo $item_grid->RowIndex ?>_kod" value="<?php echo ew_HtmlEncode($item->kod->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_kod" id="x<?php echo $item_grid->RowIndex ?>_kod" size="70" maxlength="255" value="<?php echo $item->kod->EditValue ?>"<?php echo $item->kod->EditAttributes() ?>>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->kod->ViewAttributes() ?>><?php echo $item->kod->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_kod" id="x<?php echo $item_grid->RowIndex ?>_kod" value="<?php echo ew_HtmlEncode($item->kod->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_kod" id="o<?php echo $item_grid->RowIndex ?>_kod" value="<?php echo ew_HtmlEncode($item->kod->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->rate->Visible) { // rate ?>
		<td<?php echo $item->rate->CellAttributes() ?>>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { // Add record ?>
<div id="tp_x<?php echo $item_grid->RowIndex ?>_rate" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="{value}"<?php echo $item->rate->EditAttributes() ?>></label></div>
<div id="dsl_x<?php echo $item_grid->RowIndex ?>_rate" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $item->rate->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($item->rate->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $item->rate->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
if (@$emptywrk) $item->rate->OldValue = "";
?>
</div>
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_rate" id="o<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($item->rate->OldValue) ?>">
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { // Edit record ?>
<div id="tp_x<?php echo $item_grid->RowIndex ?>_rate" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="{value}"<?php echo $item->rate->EditAttributes() ?>></label></div>
<div id="dsl_x<?php echo $item_grid->RowIndex ?>_rate" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $item->rate->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($item->rate->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $item->rate->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
if (@$emptywrk) $item->rate->OldValue = "";
?>
</div>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_VIEW) { // View record ?>
<div<?php echo $item->rate->ViewAttributes() ?>><?php echo $item->rate->ListViewValue() ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($item->rate->CurrentValue) ?>">
<input type="hidden" name="o<?php echo $item_grid->RowIndex ?>_rate" id="o<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($item->rate->OldValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->image->Visible) { // image ?>
		<td<?php echo $item->image->CellAttributes() ?>>
<?php if ($item_grid->RowAction == "insert") { // Add record ?>
<?php if ($item->CurrentAction <> "F") { ?>
<div id="old_x<?php echo $item_grid->RowIndex ?>_image">
<?php if ($item->image->LinkAttributes() <> "") { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x<?php echo $item_grid->RowIndex ?>_image">
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>&nbsp;
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="2" disabled="disabled"><?php echo $Language->Phrase("Remove") ?></label>&nbsp;
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $item->image->EditAttrs["onchange"] = "this.form.a" . $item_grid->RowIndex . "_image[2].checked=true;" . @$item->image->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="3">
<?php } ?>
<input type="file" name="x<?php echo $item_grid->RowIndex ?>_image" id="x<?php echo $item_grid->RowIndex ?>_image" size="70"<?php echo $item->image->EditAttributes() ?>>
</div>
<?php } else { ?>
<input type="hidden" name="a_image" id="a_image" value="<?php echo $item->image->Upload->Action ?>">
<?php
if ($item->image->Upload->Action == "1") {
	if (!ew_Empty($item->image->Upload->DbValue)) {
?>
<img src="ewbv8.php?tbl=<?php echo $item->TableVar ?>&fld=x_image&rnd=<?php echo ew_Random() ?>&idx=<?php echo $item_grid->RowIndex ?>&db=1" border="0">
<?php
	}
} elseif ($item->image->Upload->Action == "2") {
} else {
	if (!ew_Empty($item->image->Upload->Value)) {
?>
<img src="ewbv8.php?tbl=<?php echo $item->TableVar ?>&fld=x_image&rnd=<?php echo ew_Random() ?>&idx=<?php echo $item_grid->RowIndex ?>" border="0">
<?php
	}
}
?>
<?php } ?>
<?php } else { // Edit record ?>
<?php if ($item->CurrentAction <> "F") { ?>
<div id="old_x<?php echo $item_grid->RowIndex ?>_image">
<?php if ($item->image->LinkAttributes() <> "") { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x<?php echo $item_grid->RowIndex ?>_image">
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>&nbsp;
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="2" disabled="disabled"><?php echo $Language->Phrase("Remove") ?></label>&nbsp;
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $item->image->EditAttrs["onchange"] = "this.form.a" . $item_grid->RowIndex . "_image[2].checked=true;" . @$item->image->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="3">
<?php } ?>
<input type="file" name="x<?php echo $item_grid->RowIndex ?>_image" id="x<?php echo $item_grid->RowIndex ?>_image" size="70"<?php echo $item->image->EditAttributes() ?>>
</div>
<?php } else { ?>
<div id="old_x<?php echo $item_grid->RowIndex ?>_image">
<?php if ($item->image->LinkAttributes() <> "") { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
<?php if (!ew_Empty($item->image->Upload->DbValue) && $item->image->Upload->Action == "3") echo "[" . $Language->Phrase("Old") . "]"; ?>
</div>
<div id="new_x<?php echo $item_grid->RowIndex ?>_image">
<input type="hidden" name="a_image" id="a_image" value="<?php echo $item->image->Upload->Action ?>">
<?php
if ($item->image->Upload->Action == "1") {
	echo "[" . $Language->Phrase("Keep") . "]";
} elseif ($item->image->Upload->Action == "2") {
	echo "[" . $Language->Phrase("Remove") . "]";
} else {
	if (!ew_Empty($item->image->Upload->Value)) {
?>
<img src="ewbv8.php?tbl=<?php echo $item->TableVar ?>&fld=x_image&rnd=<?php echo ew_Random() ?>&idx=<?php echo $item_grid->RowIndex ?>" border="0">
<?php
	}
}
?>
<?php if (!ew_Empty($item->image->Upload->DbValue) && $item->image->Upload->Action == "3") echo "[" . $Language->Phrase("New") . "]"; ?>
</div>
<?php } ?>
<?php } ?>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$item_grid->ListOptions->Render("body", "right");
?>
	</tr>
<?php if ($item->RowType == EW_ROWTYPE_ADD) { ?>
<?php } ?>
<?php if ($item->RowType == EW_ROWTYPE_EDIT) { ?>
<?php } ?>
<?php
	}
	} // End delete row checking
	if ($item->CurrentAction <> "gridadd" || $item->CurrentMode == "copy")
		if (!$item_grid->Recordset->EOF) $item_grid->Recordset->MoveNext();
}
?>
<?php
	if ($item->CurrentMode == "add" || $item->CurrentMode == "copy" || $item->CurrentMode == "edit") {
		$item_grid->RowIndex = '$rowindex$';
		$item_grid->LoadDefaultValues();

		// Set row properties
		$item->ResetAttrs();
		$item->RowAttrs = array();
		if (!empty($item_grid->RowIndex))
			$item->RowAttrs = array_merge($item->RowAttrs, array('data-rowindex'=>$item_grid->RowIndex, 'id'=>'r' . $item_grid->RowIndex . '_item'));
		$item->RowType = EW_ROWTYPE_ADD;

		// Render row
		$item_grid->RenderRow();

		// Render list options
		$item_grid->RenderListOptions();

		// Add id and class to the template row
		$item->RowAttrs["id"] = "r0_item";
		ew_AppendClass($item->RowAttrs["class"], "ewTemplate");
?>
	<tr<?php echo $item->RowAttributes() ?>>
<?php

// Render list options (body, left)
$item_grid->ListOptions->Render("body", "left");
?>
	<?php if ($item->category_id->Visible) { // category_id ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<?php if ($item->category_id->getSessionValue() <> "") { ?>
<div<?php echo $item->category_id->ViewAttributes() ?>><?php echo $item->category_id->ListViewValue() ?></div>
<input type="hidden" id="x<?php echo $item_grid->RowIndex ?>_category_id" name="x<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->CurrentValue) ?>">
<?php } else { ?>
<select id="x<?php echo $item_grid->RowIndex ?>_category_id" name="x<?php echo $item_grid->RowIndex ?>_category_id"<?php echo $item->category_id->EditAttributes() ?>>
<?php
if (is_array($item->category_id->EditValue)) {
	$arwrk = $item->category_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($item->category_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
if (@$emptywrk) $item->category_id->OldValue = "";
?>
</select>
<?php } ?>
<?php } else { ?>
<div<?php echo $item->category_id->ViewAttributes() ?>><?php echo $item->category_id->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_category_id" id="x<?php echo $item_grid->RowIndex ?>_category_id" value="<?php echo ew_HtmlEncode($item->category_id->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->name->Visible) { // name ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_name" id="x<?php echo $item_grid->RowIndex ?>_name" size="70" maxlength="255" value="<?php echo $item->name->EditValue ?>"<?php echo $item->name->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->name->ViewAttributes() ?>><?php echo $item->name->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_name" id="x<?php echo $item_grid->RowIndex ?>_name" value="<?php echo ew_HtmlEncode($item->name->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_wm->Visible) { // price_wm ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_wm" id="x<?php echo $item_grid->RowIndex ?>_price_wm" size="70" maxlength="10" value="<?php echo $item->price_wm->EditValue ?>"<?php echo $item->price_wm->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->price_wm->ViewAttributes() ?>><?php echo $item->price_wm->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_wm" id="x<?php echo $item_grid->RowIndex ?>_price_wm" value="<?php echo ew_HtmlEncode($item->price_wm->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_em->Visible) { // price_em ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_em" id="x<?php echo $item_grid->RowIndex ?>_price_em" size="70" maxlength="10" value="<?php echo $item->price_em->EditValue ?>"<?php echo $item->price_em->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->price_em->ViewAttributes() ?>><?php echo $item->price_em->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_em" id="x<?php echo $item_grid->RowIndex ?>_price_em" value="<?php echo ew_HtmlEncode($item->price_em->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_wm_ahli->Visible) { // price_wm_ahli ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" size="70" value="<?php echo $item->price_wm_ahli->EditValue ?>"<?php echo $item->price_wm_ahli->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->price_wm_ahli->ViewAttributes() ?>><?php echo $item->price_wm_ahli->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_wm_ahli" value="<?php echo ew_HtmlEncode($item->price_wm_ahli->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->price_em_ahli->Visible) { // price_em_ahli ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" size="70" value="<?php echo $item->price_em_ahli->EditValue ?>"<?php echo $item->price_em_ahli->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->price_em_ahli->ViewAttributes() ?>><?php echo $item->price_em_ahli->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" id="x<?php echo $item_grid->RowIndex ?>_price_em_ahli" value="<?php echo ew_HtmlEncode($item->price_em_ahli->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->weight->Visible) { // weight ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_weight" id="x<?php echo $item_grid->RowIndex ?>_weight" size="70" value="<?php echo $item->weight->EditValue ?>"<?php echo $item->weight->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->weight->ViewAttributes() ?>><?php echo $item->weight->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_weight" id="x<?php echo $item_grid->RowIndex ?>_weight" value="<?php echo ew_HtmlEncode($item->weight->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->kod->Visible) { // kod ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<input type="text" name="x<?php echo $item_grid->RowIndex ?>_kod" id="x<?php echo $item_grid->RowIndex ?>_kod" size="70" maxlength="255" value="<?php echo $item->kod->EditValue ?>"<?php echo $item->kod->EditAttributes() ?>>
<?php } else { ?>
<div<?php echo $item->kod->ViewAttributes() ?>><?php echo $item->kod->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_kod" id="x<?php echo $item_grid->RowIndex ?>_kod" value="<?php echo ew_HtmlEncode($item->kod->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->rate->Visible) { // rate ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<div id="tp_x<?php echo $item_grid->RowIndex ?>_rate" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="{value}"<?php echo $item->rate->EditAttributes() ?>></label></div>
<div id="dsl_x<?php echo $item_grid->RowIndex ?>_rate" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $item->rate->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($item->rate->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $item->rate->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
if (@$emptywrk) $item->rate->OldValue = "";
?>
</div>
<?php } else { ?>
<div<?php echo $item->rate->ViewAttributes() ?>><?php echo $item->rate->ViewValue ?></div>
<input type="hidden" name="x<?php echo $item_grid->RowIndex ?>_rate" id="x<?php echo $item_grid->RowIndex ?>_rate" value="<?php echo ew_HtmlEncode($item->rate->FormValue) ?>">
<?php } ?>
</td>
	<?php } ?>
	<?php if ($item->image->Visible) { // image ?>
		<td>
<?php if ($item->CurrentAction <> "F") { ?>
<div id="old_x<?php echo $item_grid->RowIndex ?>_image">
<?php if ($item->image->LinkAttributes() <> "") { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, $item->image->UploadPath) . $item->image->Upload->DbValue ?>" border=0<?php echo $item->image->ViewAttributes() ?>>
<?php } elseif (!in_array($item->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</div>
<div id="new_x<?php echo $item_grid->RowIndex ?>_image">
<?php if (!empty($item->image->Upload->DbValue)) { ?>
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>&nbsp;
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="2" disabled="disabled"><?php echo $Language->Phrase("Remove") ?></label>&nbsp;
<label><input type="radio" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $item->image->EditAttrs["onchange"] = "this.form.a" . $item_grid->RowIndex . "_image[2].checked=true;" . @$item->image->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a<?php echo $item_grid->RowIndex ?>_image" id="a<?php echo $item_grid->RowIndex ?>_image" value="3">
<?php } ?>
<input type="file" name="x<?php echo $item_grid->RowIndex ?>_image" id="x<?php echo $item_grid->RowIndex ?>_image" size="70"<?php echo $item->image->EditAttributes() ?>>
</div>
<?php } else { ?>
<input type="hidden" name="a_image" id="a_image" value="<?php echo $item->image->Upload->Action ?>">
<?php
if ($item->image->Upload->Action == "1") {
	if (!ew_Empty($item->image->Upload->DbValue)) {
?>
<img src="ewbv8.php?tbl=<?php echo $item->TableVar ?>&fld=x_image&rnd=<?php echo ew_Random() ?>&idx=<?php echo $item_grid->RowIndex ?>&db=1" border="0">
<?php
	}
} elseif ($item->image->Upload->Action == "2") {
} else {
	if (!ew_Empty($item->image->Upload->Value)) {
?>
<img src="ewbv8.php?tbl=<?php echo $item->TableVar ?>&fld=x_image&rnd=<?php echo ew_Random() ?>&idx=<?php echo $item_grid->RowIndex ?>" border="0">
<?php
	}
}
?>
<?php } ?>
</td>
	<?php } ?>
<?php

// Render list options (body, right)
$item_grid->ListOptions->Render("body", "right");
?>
	</tr>
<?php
}
?>
</tbody>
</table>
<?php if ($item->CurrentMode == "add" || $item->CurrentMode == "copy") { ?>
<input type="hidden" name="a_list" id="a_list" value="gridinsert">
<input type="hidden" name="key_count" id="key_count" value="<?php echo $item_grid->KeyCount ?>">
<?php echo $item_grid->MultiSelectKey ?>
<?php } ?>
<?php if ($item->CurrentMode == "edit") { ?>
<input type="hidden" name="a_list" id="a_list" value="gridupdate">
<input type="hidden" name="key_count" id="key_count" value="<?php echo $item_grid->KeyCount ?>">
<?php echo $item_grid->MultiSelectKey ?>
<?php } ?>
<input type="hidden" name="detailpage" id="detailpage" value="item_grid">
</div>
<?php

// Close recordset
if ($item_grid->Recordset)
	$item_grid->Recordset->Close();
?>
<?php if (($item->CurrentMode == "add" || $item->CurrentMode == "copy" || $item->CurrentMode == "edit") && $item->CurrentAction != "F") { // add/copy/edit mode ?>
<div class="ewGridLowerPanel">
<?php if ($item->AllowAddDeleteRow) { ?>
<?php if ($Security->IsLoggedIn()) { ?>
<span class="phpmaker">
<a href="javascript:void(0);" onclick="ew_AddGridRow(this);"><img src='phpimages/addblankrow.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("AddBlankRow")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("AddBlankRow")) ?>' width='16' height='16' border='0'></a>&nbsp;&nbsp;
</span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
</td></tr></table>
<?php if ($item->Export == "" && $item->CurrentAction == "") { ?>
<?php } ?>
<?php
$item_grid->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<?php
$item_grid->Page_Terminate();
$Page =& $MasterPage;
?>
